package cn.myzf.ftp.cogradient.netty.listeners;

import cn.hutool.core.thread.ThreadUtil;
import cn.myzf.ftp.cogradient.netty.thread.NettyThread;
import cn.myzf.ftp.cogradient.netty.utils.PropertiesUtil;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;

/**
 * @package cn.myzf.ftp.cogradient.netty.listen
 * @Date Created in 2019/12/29 18:03
 * @Author myzf
 */
public class Nettylistener implements SmartApplicationListener {

    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> event) {
        return ApplicationStartedEvent.class.isAssignableFrom(event);
    }

    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        NettyThread nettyThread = new NettyThread(Integer.valueOf(PropertiesUtil.getConfig("netty.port")));
        ThreadUtil.execute(nettyThread);
    }
}
